package com.exam.Service;

import com.exam.Entity.JudgeQuestion;
import com.exam.Mapper.JudgeQuestionMapper;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class JudgeQuestionService {

    @Autowired
    private JudgeQuestionMapper judgeQuestionMapper;


    public List<JudgeQuestion> findByIdAndType(Integer paperId) {
        return judgeQuestionMapper.findByIdAndType(paperId);
    }


    public List<JudgeQuestion> findAll(int page,int size) {
        //设置分页参数
        PageHelper.startPage(page, size);
        //执行查询
        List<JudgeQuestion> result = judgeQuestionMapper.findAll();
        // 包装分页结果
        PageInfo<JudgeQuestion> pageInfo = new PageInfo<>(result);

        return pageInfo.getList();
    }


    public JudgeQuestion findOnlyQuestionId() {
        return judgeQuestionMapper.findOnlyQuestionId();
    }


    public int add(JudgeQuestion judgeQuestion) {
        return judgeQuestionMapper.add(judgeQuestion);
    }


    public int deleteById(Integer id) {
        return judgeQuestionMapper.deleteById(id);
    }

    public List<Integer> findBySubject(String subject, Integer pageNo) {
        return judgeQuestionMapper.findBySubject(subject,pageNo);
    }
}
